package com.ricchieri.service;

import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.transaction.annotation.Transactional;

import com.ricchieri.dao.interf.ICancelationTypeDao;
import com.ricchieri.filter.BasicFilter;
import com.ricchieri.model.CancelationType;
import com.ricchieri.service.interf.ICancelationTypeService;
import com.ricchieri.util.FacesUtil;

@Transactional(readOnly = true)
public class CancelationTypeService implements ICancelationTypeService, Serializable {
	private static final long serialVersionUID = 204041156861760273L;
	ICancelationTypeDao cancelationTypeDao;
		
	@Override
	@Transactional(readOnly = true)
	public List<CancelationType> getAllCancelationType() {
		BasicFilter cancelationTypeFilter = new BasicFilter();
		return cancelationTypeDao.getAllCancelationType(cancelationTypeFilter );
	}

	public ICancelationTypeDao getCancelationTypeDao() {
		return cancelationTypeDao;
	}

	public void setCancelationTypeDao(ICancelationTypeDao cancelationTypeDao) {
		this.cancelationTypeDao = cancelationTypeDao;
	}
	
	@Override
	public CancelationType getCancelationById(BasicFilter cancelationTypeFilter) {
		return getCancelationTypeDao().getCancelationTypeById(cancelationTypeFilter);
	}
	
	@Override
	public Map<String, String> getComboCancelationTypes() {
		List<CancelationType> cancelationValues = this.getAllCancelationType();

		HashMap<String, String> cancelationTypes = new HashMap<String, String>();

		for (CancelationType cancelationType : cancelationValues) {
			cancelationTypes.put(FacesUtil.getMessage(cancelationType.getDescription()), String.valueOf(cancelationType.getId()));
		}

		return cancelationTypes;
	}	
	
	
}
